package www.wmx.com.xssc.util.common;

import www.wmx.com.xssc.domain.mb.RbtKjjlMbJcyjRank;
import www.wmx.com.xssc.domain.mb.RbtKjjlMbJcyjj;
import www.wmx.com.xssc.domain.mb.RbtKjjlMbTy;
import www.wmx.com.xssc.service.IRbtKjjlMbJcyjRankService;
import www.wmx.com.xssc.service.IRbtKjjlMbJcyjjService;
import www.wmx.com.xssc.service.IRbtKjjlMbTyService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
@Data
public class MbReadUtil {

    @Resource
    private IRbtKjjlMbTyService kjjlMbTyService;

    @Resource
    private IRbtKjjlMbJcyjRankService kjjlMbJcyjRankService;

    @Resource
    private IRbtKjjlMbJcyjjService kjjlMbJcyjjService;

    // 作者排名：
    private RbtKjjlMbJcyjRank kjjlMbJcyjRank;

    // 通用模板
    private List<RbtKjjlMbTy> kjjlMbTyList=new ArrayList<>();

    // 基础研究奖根据等级要求论文的信息：
    private List<RbtKjjlMbJcyjj> kjjlMbJcyjjsList;

    public void init(){
        //  通用模板信息获取：
        List<RbtKjjlMbTy> kjjlMbTyList = kjjlMbTyService.lambdaQuery().list();
        for (RbtKjjlMbTy mbTy : kjjlMbTyList) {
            List<Integer> list = new ArrayList<>();
            String contain = mbTy.getContain();
            String[] split = contain.split(",");
            for (String s : split) {
                list.add(Integer.parseInt(s));
            }
            mbTy.setContainList(list);
        }
        this.kjjlMbTyList.addAll(kjjlMbTyList);
        // 基础研究奖作者排名：
        RbtKjjlMbJcyjRank rbtKjjlMbJcyjRank = kjjlMbJcyjRankService.lambdaQuery().one();
        this.kjjlMbJcyjRank = rbtKjjlMbJcyjRank;
        // 基础研究奖不同等级下论文的要求：
        List<RbtKjjlMbJcyjj> rbtKjjlMbJcyjjs = kjjlMbJcyjjService.lambdaQuery().list();
        this.kjjlMbJcyjjsList = rbtKjjlMbJcyjjs;

    }

}
